<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2016/10/10
  Time: 16:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>Title</title>
    <script type="application/javascript" src="../../js/gtimp3/declaration.js"></script>
</head>
<script type="application/javascript">
    $(function () {
        $("#containerNo_show").autocomplete({
                                                minLength: 0,
                                                autoFocus: true,
                                                matchContains: true,
                                                source: function (request, response) {
                                                    var data = {
                                                        declarationId: '${declarationId}'
                                                    };
                                                    $.ajax({
                                                               url: "../base/getContainerNoByDeclarationId?tdateaa="
                                                                    + timeNum(),
                                                               data: data,
                                                               success: function (data) {
                                                                   response($.map(data,
                                                                                  function (item) {
                                                                                      return {
                                                                                          key: item,
                                                                                          value: item
                                                                                      }
                                                                                  }));
                                                               }
                                                           });
                                                }, select: function (event, ui) {
                $("#containerNo").val(ui.item.key);
                $("#containerNo_show").val(ui.item.value);
                return false;
            }
                                            });
        $("#containerNo_show").on("click", function () {
            $("#containerNo_show").autocomplete("search", "");
        });

        $("#inspectionCommodityId_show").autocomplete({
                                                          minLength: 0,
                                                          autoFocus: true,
                                                          matchContains: true,
                                                          source: function (request, response) {
                                                              var data = {
                                                                  declarationId: '${declarationId}'
                                                              };
                                                              $.ajax({
                                                                         url: "../base/getCommodityByDeclarationId?tdateaa="
                                                                              + timeNum(),
                                                                         data: data,
                                                                         success: function (data) {
                                                                             response($.map(data,
                                                                                            function (item) {
                                                                                                return {
                                                                                                    key: item[0],
                                                                                                    value: item[1]
                                                                                                }
                                                                                            }));
                                                                         }
                                                                     });
                                                          }, select: function (event, ui) {
                $("#inspectionCommodityId").val(ui.item.key);
                $("#inspectionCommodityId_show").val(ui.item.value);
                return false;
            }
                                                      });
        $("#inspectionCommodityId_show").on("click", function () {
            $("#inspectionCommodityId_show").autocomplete("search", "");
        });
    });

    function doSubmit() {
        var declarationId = '${declarationId}';
        var containerNo = $("#containerNo").val();
        var inspectionCommodityId = $("#inspectionCommodityId").val();
        if (!declarationId) {
            alert("提交错误，请联系管理员！");
            return;
        }
        if (!containerNo) {
            alert("请选择查验柜号！");
            return;
        }
        if (!inspectionCommodityId) {
            alert("请选择查验商品！");
            return;
        }
        window.parent.location.href =
                "/inspectionGoods/addPage?declarationId=" + declarationId + "&containerNo="
                + containerNo + "&inspectionCommodityId=" + inspectionCommodityId;
    }
</script>
<body>
<div id="inspectionGoodsDIV">
    <div style="margin: 10px 20px;line-height:2.5;">
        查验柜号：<input id="containerNo_show" name="containerNo_show" style="width: 400px;"/>
        <input id="containerNo" name="containerNo" type="hidden"/><br/>
        查验商品：<input id="inspectionCommodityId_show" name="inspectionCommodityId_show"
                    style="width: 400px;"/>
        <input id="inspectionCommodityId" name="inspectionCommodityId" type="hidden"/>
        <div align="center">
            <button onclick="doSubmit();">确定</button>
            <button onclick="window.parent.jw.close();">关闭</button>
        </div>
    </div>
</div>
</body>
</html>
